package com.li.service;

import com.li.mapper.StudentMapper;
import com.li.pojo.Class;
import com.li.pojo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentService {
    @Autowired
    StudentMapper studentMapper;
    public Student queryStudent(Student student){
        return studentMapper.queryStudent(student);
    }
    public boolean addStudent(Student student){
        if(studentMapper.queryStudentBySno(student)==null){
            studentMapper.insertStudent(student);
            return true;
        }
        return false;
    }
    public boolean deleteStudent(Student student){
        if(studentMapper.queryStudentBySno(student)!=null){
            studentMapper.deleteStudent(student);
            return true;
        }
        return false;
    }
    public boolean updateStudent(Student student){
        studentMapper.updateStudent(student);
        return  true;
    }
    public List<Student> allStudent(){
        return studentMapper.listStudent();
    }
    public List<Class> allClass(){
        return studentMapper.listClass();
    }
}
